@extends('admin.layout')
@section('content')
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="col-md-12" id="content">
            <div class="app_content_div" id="app_content_div_301Index">
                <h3>直播录播管理</h3>
            </div>
            <div>
                <div style="float:right;">
                    <a href="/adm/video/add-video"> <button type="button" class="btn btn-primary">新增视频</button></a>
                </div>
            </div>
<table class="table table-striped">
    <thead>
    <tr>
        <th>id</th>
        <th>标题</th>
        <th>科室</th>
        <th>专家</th>
        <th>类型</th>
        <th>直播开始时间</th>
        <th>直播结束时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    @foreach($video as $v)

            <tbody>
            <tr>
                <th>{{$v->id}}</th>
                <th>{{$v->title}}</th>
                <?php
                $expert = \App\Models\Expert::find($v->expert_id);
                ?>
                <th>{{$expert->ks}}</th>
                <th>{{$expert->name}}</th>
                @if($v->type==1)<th>直播</th>@else()<th>录播</th>@endif
                <th>{{$v->start_at}}</th>
                <th>{{$v->end_at}}</th>
                <th>

                    <a href="/adm/video/edit/{{$v->id}}"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a> &nbsp;&nbsp;&nbsp;
                    <a onclick="del({{$v->id}});"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>



                </th>
            </tr>
            </tbody>
    @endforeach
</table>


{{$video->links('front.paginate')}}
                </div>
                </div>
            <script>
                function del(id){
                    var conf = confirm('你确定要删除这条记录吗？');
                    if(conf==true){
                        $.ajax({
                            url:'/adm/video/destroy/'+id,
                            type:'DELETE',
                            dataType:'json',
                            data:{'_token':'{{csrf_token()}}'},
                            success:function (data){
                                alert('删除成功');
                                location.href='/adm/video/video-list';
                            },
                            error:function (data){}
                        });
                    }}
            </script>
@endsection
